<template>
    <div>
      <h1>继承实验===原型继承</h1>
      <p>
        让新实例的原型等于父类的实例
      </p>
      <button @click="prototypeExtends">原型继承</button>
      <button @click="protoLian">原型链继承</button>
    </div>
</template>

<script>
  export default {
    name: 'extends',
    mounted () {

    },
    methods:{
      prototypeExtends(){
        //父类
        function Person (name) {
          this.fatherName = name;
          this.sum = function () {
            console.log(this.fatherName)
          }
        }
        Person.prototype.age=40;
        function Son () {
          this.sex = "男";
          this.printOut = function () {
            console.log(this.sex)
          }
        }
        Son.prototype = new Person('父亲实例')
        var son1 = new Son();
        console.log(son1);
      },
      protoLian(){

      }
    }
  }
</script>

<style scoped>

</style>
